package map.exercise;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-02-14
 * Time:3:05
 */
@SuppressWarnings("all")
public class Exercise1 {
    public static void main(String[] args) {
        HashMap<String, Employee> employees = new HashMap<>();
        employees.put("123456", new Employee("zhangsan", "123456", 3000));
        employees.put("234567", new Employee("lisi", "234567", 1000));
        employees.put("345678", new Employee("wangwu", "345678", 5000));
        Set<Map.Entry<String, Employee>> entries = employees.entrySet();
        for (Map.Entry<String, Employee> entry : entries) {
            if (entry.getValue().getSalary() > 1800) {
                System.out.println(entry);
            }
        }
    }
}

@SuppressWarnings("all")
class Employee {
    private String name;
    private String id;
    private int salary;

    public Employee(String name, String id, int salary) {
        this.name = name;
        this.id = id;
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", id='" + id + '\'' +
                ", salary=" + salary +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Employee employee = (Employee) o;
        return salary == employee.salary && Objects.equals(name, employee.name) && Objects.equals(id, employee.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, id, salary);
    }

    public int getSalary() {
        return salary;
    }
}
